import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

/**
 *
 * @ProjectName:    manager_page
 * @ClassName:      base_page
 * @Description:    dart类作用描述
 * @Author:         孙浩
 * @QQ:             243280864
 * @CreateDate:     2020/11/25 12:33 AM
 */
class BaseMPage extends StatelessWidget {
  String imgPath, title;
  IndexedWidgetBuilder itemBuilder;
  int itemCount;
  Widget child;

  BaseMPage(this.imgPath, this.itemBuilder, this.itemCount, this.title,
      {this.child});

  @override
  Widget build(BuildContext context) {
    return NestedScrollView(
        headerSliverBuilder: (ctx, scroll) => [
              SliverAppBar(
                expandedHeight: 300,
                flexibleSpace: FlexibleSpaceBar(
                  background: Container(
                    color: Colors.white,
                    child: ConstrainedBox(
                      constraints: BoxConstraints.expand(),
                      child: Hero(
                          tag: imgPath,
                          child: Image.asset(
                            imgPath,
                            fit: BoxFit.cover,
                            color: Colors.black26,
                            colorBlendMode: BlendMode.darken,
                          )),
                    ),
                  ),
                  centerTitle: false,
                  collapseMode: CollapseMode.parallax,
                  title: Text(title),
                ),
                pinned: true,
              )
            ],
        body: child ??
            ListView.separated(
              padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30),
              physics: ClampingScrollPhysics(),
              itemBuilder: itemBuilder,
              itemCount: itemCount,
              separatorBuilder: (BuildContext context, int index) {
                return Container(
                  height: 30,
                );
              },
            ));
  }
}
